<include file="common:__head__"/>
<div class="permissions-tabs">
    <a class="role tabs-bg" href="{:U('members/member_list')}">会员列表</a>
</div>
<div class="permissions-content">
    <form class="form-horizontal" id="memberForm" action="{:U('Members/addmember')}" method="post">
        <div class="permissions-le">
            <span class="add-admin"><a href="javascript:history.go(-1)"></a>添加会员</span>
            <div class="add-admin-ipt">
                <span><i>*</i>会员名称:</span>
                <input type="text" id="mem_name" name="mem_name" placeholder="请填写会员姓名" class="w200"/>
            </div>
            <div class="add-admin-ipt">
                <span><i>*</i>手机号:</span>
                <input type="text" name="mobile" id="mem_mobile" data-type="number" maxlength="11" onchange="checkIsset(this.value);" placeholder="请填写管理员手机" class="w200"/>
                <span id="err_mobile" style="margin-left:10px;"></span>
            </div>
            <div class="add-admin-ipt">
                <span>&nbsp;&nbsp;&nbsp;&nbsp;邮箱:</span>
                <input type="text" name="email" id="mem_email" placeholder="请填写会员邮箱" class="w200"/>
            </div>
            <div class="add-admin-ipt">
                <span><i>*</i>密码:</span>
                <input type="text" name="pwd" id="pwd" placeholder="请填写会员密码" class="w200"/>
            </div>
            <div class="add-admin-ipt">
                <span></span>
                <a class="btn-lg btn-blue" id="submitBtn">保存</a>
            </div>
        </div>
    </form>
    <div class="permissions-ri">
        <a href="" class="permissions-help">帮助和服务</a>
    </div>
</div>

</div>
<script type="text/javascript">
    $(function(){
        $('#submitBtn').click(function () {
            var mem_mobile = $('#mem_mobile').val();
            var mem_name = $('#mem_name').val();
            var mem_email = $('#mem_email').val();
            var pwd = $('#pwd').val();
            if(!mem_name){
                layer.alert('请输入会员名称');
                return false;
            }
            if (!checkMobile(mem_mobile)) {
                layer.alert('手机号格式不正确');
                return false;
            }
            if(mem_email && !checkEmail(mem_email)){
                layer.alert('邮箱格式不正确');
                return false;
            }
            if(!pwd){
                layer.alert('请输入会员密码');
                return false;
            }
            $("#memberForm").submit();
        });

    });
    function checkIsset( $searchKey)
    {
        $.ajax({
            url: "{:U('Agent/searchIsset')}",
            type: "post",
            data: {skey : $searchKey},
            dataType:'JSON',
            success: function (msg)
            {
                if(msg.status == 'success'){
                    $("#err_mobile").show();
                    $("#err_mobile").css("color","green");
                    $("#err_mobile").text("手机号码可用");
                }else{
                    $("#err_mobile").show();
                    $("#err_mobile").css("color","red");
                    $("#err_mobile").text(msg.msg);
                }
            }
        });
    }
</script>
<include file="common:__foot__"/>